Skip to main content

Prompt Engineering

A prompt template is made with LangChain for prompt engineering.

from langchain.prompts import PromptTemplate

prompt_template = PromptTemplate(
template="""
---
##Instructions
---

---
##Context
---

---
##Examples
---

---
##Query:
{query}
---
""", input_variables=["query"]
)

The above is the basic template of a prompt to answer queries, with section markers to differentiate between Primary content (the query), instructions and examples.

The chat history is stroed in the agent memory to provide context.

The final agent is asked to explain its chain-of-thought in the answer for verification.

Using the prompt engineering techniques of demarcation, breaking down a complex task, few-shot learning and chain of thought, the bot achieves a considerable accuracy.